home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / V15N04.ZIP / WARPCA.ZIP / WCABSRC.ZIP / CONFIRM.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-18  |  2.8 KB  |  111 lines

  1. // DConfirmDlg -- Class implementation
  2. #include <assert.h>
  3. #include <cstring.h>
  4. #include <dir.h>
  5. #include <classlib\arrays.h>
  6. #include <owl\owlpch.h>
  7. #include <owl\dialog.h>
  8. #include <owl\edit.h>
  9. #include <owl\static.h>
  10. #include <owl\button.h>
  11. #include "os2api.h"
  12. #include "resource.h"
  13. #include "confirm.h"
  14.  
  15. #define DID_OK      1
  16. #define DID_CANCEL  2
  17.  
  18. DEFINE_RESPONSE_TABLE1(DConfirmDlg, TDialog)
  19.     EV_CHILD_NOTIFY(IDC_CONFIRM_ALL, BN_CLICKED, OnAllBoxClick),
  20.     EV_CHILD_NOTIFY(DID_OK, BN_CLICKED, CmOk),
  21. END_RESPONSE_TABLE;
  22.  
  23.  
  24. DConfirmDlg::DConfirmDlg(TWindow *parent, int *pbConfirmDelete,
  25.                         int *pbConfirmReplace, int *pbConfirmCopy,
  26.                         int *pbConfirmAll) : TDialog(parent, IDD_SET_CONFIRM_OPTS_DLG, 0)
  27. {
  28.     bOldConfirmDelete = FALSE;
  29.     bOldConfirmReplace = FALSE;
  30.     bOldConfirmCopy = FALSE;
  31.     bOldConfirmAll = FALSE;
  32.  
  33.     if(!pbConfirmDelete ||
  34.         !pbConfirmDelete ||
  35.         !pbConfirmCopy ||
  36.         !pbConfirmAll)
  37.     {
  38.         MessageBox("Bad pointer in DConfirmDlg::DConfirmDlg!", "Error", MB_ICONSTOP);
  39.         return;
  40.     }
  41.  
  42.     pbOldConfirmDelete = pbConfirmDelete;
  43.     pbOldConfirmReplace = pbConfirmReplace;
  44.     pbOldConfirmCopy = pbConfirmCopy;
  45.     pbOldConfirmAll = pbConfirmAll;
  46.  
  47.     bOldConfirmDelete = *pbOldConfirmDelete;
  48.     bOldConfirmReplace = *pbOldConfirmReplace;
  49.     bOldConfirmCopy = *pbOldConfirmCopy;
  50.     bOldConfirmAll = *pbOldConfirmAll;
  51. }
  52.  
  53. void DConfirmDlg::SetupWindow()
  54. {
  55.     TDialog::SetupWindow();
  56.  
  57.     // If confirm all, then other checkboxes are disabled.
  58.  
  59.     if(bOldConfirmAll)
  60.     {
  61.         WinEnableWindow(GetDlgItem(IDC_CONFIRM_DELETE), 0);
  62.         WinEnableWindow(GetDlgItem(IDC_CONFIRM_REPLACE), 0);
  63.         WinEnableWindow(GetDlgItem(IDC_CONFIRM_COPY), 0);
  64.  
  65.         CheckDlgButton(IDC_CONFIRM_ALL, TRUE);
  66.     }
  67.     else
  68.     {
  69.         CheckDlgButton(IDC_CONFIRM_DELETE, bOldConfirmDelete);
  70.         CheckDlgButton(IDC_CONFIRM_COPY, bOldConfirmCopy);
  71.         CheckDlgButton(IDC_CONFIRM_REPLACE, bOldConfirmReplace);
  72.     }
  73. }
  74.  
  75. void DConfirmDlg::OnAllBoxClick()
  76. {
  77.     // Check to see if this is turned off/on enable or disable other 3 options
  78.     // accordingly.
  79.     int rc = IsDlgButtonChecked(IDC_CONFIRM_ALL);
  80.     {
  81.         WinEnableWindow(GetDlgItem(IDC_CONFIRM_DELETE), !rc);
  82.         WinEnableWindow(GetDlgItem(IDC_CONFIRM_REPLACE), !rc);
  83.         WinEnableWindow(GetDlgItem(IDC_CONFIRM_COPY), !rc);
  84.     }
  85.  
  86. }
  87.  
  88. void DConfirmDlg::CmOk()
  89. {
  90.     // Retrieve new settings and write them back to parent's data.
  91.     if(IsDlgButtonChecked(IDC_CONFIRM_ALL))
  92.     {
  93.         *pbOldConfirmDelete = FALSE;
  94.         *pbOldConfirmCopy = FALSE;
  95.         *pbOldConfirmReplace = FALSE;
  96.  
  97.         *pbOldConfirmAll = TRUE;
  98.     }
  99.     else
  100.     {
  101.         *pbOldConfirmAll = FALSE;
  102.  
  103.         *pbOldConfirmDelete = IsDlgButtonChecked(IDC_CONFIRM_DELETE);
  104.         *pbOldConfirmCopy = IsDlgButtonChecked(IDC_CONFIRM_COPY);
  105.         *pbOldConfirmReplace = IsDlgButtonChecked(IDC_CONFIRM_REPLACE);
  106.     }
  107.     CloseWindow(TRUE);
  108. }
  109.  
  110.  
  111.